﻿@using ST = EmoneyWeiXinCommon.StringTools;
@{
    ViewBag.Title = "粉丝消息管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="@ST.GetStaticFile("My97DatePicker/skin/WdatePicker.css")" rel="stylesheet" />
<script src="@ST.GetStaticFile("My97DatePicker/WdatePicker.js")"></script>
<script src="@ST.GetStaticFile("Static/Js/geo.js")"></script>

<div class="right">
    <h3>粉丝消息管理</h3>
    <!--manage-->
    <div class="manage">
        <!--manage_top-->
        <div class="manage_top">
            <ul class="manage_top_ul">
            </ul>
            <div class="manage_register">
                <p><span>微信昵称：</span><input type="text" id="txtnickname"></p>
                <p>
                    <span>关注时间：</span>
                    <input type="date" class="manage_register_text" id="txtStartTime">
                    <span class="manage_register_font">至</span>
                    <input type="date" class="manage_register_text" id="txtEndTime">
                </p>
            </div>
            <div class="manage_register">
                <p>
                    <span>性别：</span><select id="selsex">
                        <option value="">请选择</option>
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                </p>
                <p>
                    <span>微信所在地：</span>
                    <select class="manage_register_text" name="province" id="s1" onchange="changeselect1(this.value)">
                        <option value="">请选择</option>
                        <option value="北京">北京</option>
                        <option value="上海">上海</option>
                        <option value="天津">天津</option>
                        <option value="重庆">重庆</option>
                        <option value="河北">河北</option>
                        <option value="山西">山西</option>
                        <option value="辽宁">辽宁</option>
                        <option value="吉林">吉林</option>
                        <option value="黑龙江">黑龙江</option>
                        <option value="江苏">江苏</option>
                        <option value="浙江">浙江</option>
                        <option value="安徽">安徽</option>
                        <option value="福建">福建</option>
                        <option value="江西">江西</option>
                        <option value="山东">山东</option>
                        <option value="河南">河南</option>
                        <option value="湖北">湖北</option>
                        <option value="湖南">湖南</option>
                        <option value="广东">广东</option>
                        <option value="甘肃">甘肃</option>
                        <option value="陕西">陕西</option>
                        <option value="内蒙古">内蒙古</option>
                        <option value="广西">广西</option>
                        <option value="四川">四川</option>
                        <option value="贵州">贵州</option>
                        <option value="云南">云南</option>
                        <option value="西藏">西藏</option>
                        <option value="海南">海南</option>
                        <option value="宁夏">宁夏</option>
                        <option value="青海">青海</option>
                        <option value="新疆">新疆</option>
                        <option value="香港">香港</option>
                        <option value="澳门">澳门</option>
                        <option value="台湾">台湾</option>
                    </select>
                    <span class="manage_register_font"></span>
                    <select class="manage_register_text" name="city" id="s2">
                    </select>
                </p>
            </div>
            <div class="manage_register">
                <p>
                    <span>分组：</span><select><option></option>
                    </select>
                </p>
            </div>
            @*<div class="manage_register">
                <div class="manage_register_user">
                    <span class="manage_register_user_left">用户标签：</span>
                    <div class="manage_register_user_right" id="divLable">
                    </div>
                </div>
            </div>*@
            <p class="manage_add">
                <a href="javascript:void(0);" id="btnSelect">查询</a>
            </p>
            <!--manage_top end-->
            <p class="manage_line"></p>
            <!--manage_bottom-->
            <div class="manage_bottom">
                <!--manage_batch-->
                <div class="manage_batch">
                    <ul>
                        <li>
                            <span class="manage_batch_left">
                                <input type="checkbox"></span>
                            <div class="manage_batch_center"><a href="javascript:void(0);" class="manage_batch_a">批量回复</a></div>
                        </li>
                        <div id="divContentStockD">
                        </div>
                    </ul>
                </div>
                <!--manage_batch end-->
                <!--manage_page-->
                <div class="manage_page" id="manage_page">
                </div>
                <!--manage_page end-->
            </div>
            <!--manage_bottom end-->
        </div>
        <!--manage end-->
    </div>
</div>
<script type="text/javascript">
    var weixinid = "";
    var pageIndex = 1;
    var pageSize = 15;
    var pageCount = 1;
    $(window).ready(function () {
        createMemu();
        $("#btnSelect").click(function () {
            getContent();
        })

        $("#txtStartTime,#txtEndTime").click(function () {
            WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' });
        });

    })

    //创建labs
    function createMemu() {
        $.ajax({
            type: "get",
            url: "@ST.GetTrendsFile("BaseConfiguration/WeixinUserMemu")" + "?random=" + Math.random(),
            async: true,
            data: { weixinid: weixinid },
            dataType: "html",
            success: function (result) {
                $(".manage_top_ul").html(result);
                $(".manage_top_ul li").click(function () {
                    $(".manage_top_ul li").removeClass("manage_top_A");
                    $(this).addClass("manage_top_A");
                    getContent();
                });
                getContent();
            }
        });
    }

    function PageCountHtml() {
        var groupid = "";
        
        $.ajax({
            type: "get",
            url: "@ST.GetTrendsFile("StockDoctorlog/Index_dataNum")",
            async: true,
            data: {
                weixinid: weixinid, nickname: $("#txtnickname").val(),
                starttime: $("#txtStartTime").val(),
                endtime: $("#txtEndTime").val(),
                sex: $("#selsex").val(),
                sf: $("#s1").val(),
                dq: $("#s2").val(),
                groupid: groupid
            },
            dataType: "html",
            success: function (result) {
                pageCount = Math.ceil(result / pageSize);
                if (pageCount == 0) {
                    pageCount = 1;
                }
                $("#manage_page").html(PageHtml(pageIndex, pageCount));
                $("#manage_page .manage_page_right").click(function () {
                    pageIndex = parseInt($("#txtPageNum").val()) + parseInt($(this).attr("tname"));
                    $("#manage_page").html(PageHtml(pageIndex, pageCount));
                    getContent();
                });
                $("#manage_page .tiaozhuan").click(function () {
                    var pageNum = $("#txtPageNum").val();
                    try {
                        pageIndex = parseInt(pageNum);
                    } catch (e) {
                        alert("请输入数字");
                        return false;
                    }
                    if (pageNum > 0 && pageNum <= pageCount) {
                        $("#manage_page").html(PageHtml(pageIndex, pageCount));
                        getContent();
                    }
                    else {
                        alert("当前数字超出范围");
                        return false;
                    }
                })
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("error");
            }
        });
    }

    function getContent() {
        $(".manage_top_ul .manage_top_A").each(function () {
            weixinid = $(this).attr("typeid");
        })

        //绑定标签
        //bindCheckBoxList();

        var groupid = "";
        //$(".divLable .input").each(function () {
        //    if ($(this).attr("checked") != undefined) {
        //        if (groupid == "") {
        //            groupid += $(this).val();
        //        }
        //        else {
        //            groupid += "," + $(this).val();
        //        }
        //    }
        //})
        $.ajax({
            type: "get",
            url: "@ST.GetTrendsFile("StockDoctorlog/Index_Data")" + "?random=" + Math.random(),
            async: true,
            data: {
                pageindex: pageIndex,
                weixinid: weixinid,
                nickname: $("#txtnickname").val(),
                starttime: $("#txtStartTime").val(),
                endtime: $("#txtEndTime").val(),
                sex: $("#selsex").val(),
                sf: $("#s1").val(),
                dq: $("#s2").val(),
                groupid: groupid
            },
            dataType: "html",
            success: function (result) {
                $("#divContentStockD").html(result);
                PageCountHtml();
            }
        });
    }

   @* function bindCheckBoxList(url) {
        $.ajax({
            url: "@ST.GetTrendsFile("WXUser/QueryUserLabelList")",
            type: "POST",
            async: true,
            data: { weixinid: weixinid },
            success: function (data) {
                datatype = eval(data);
                if (datatype) {
                    var html = '';
                    for (var i = 0; i < datatype.length; i++) {
                        html += ' <input type="checkbox" name="chexBox" value="' + datatype[i]["id"] + '">' + datatype[i]["name"] + '</span>';
                    }
                    $("#divLable").html(html);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                //alert(errorThrown);
            }
        });
    }*@
</script>
